package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.ChaXunDetailBean1;
import com.weetop.aklyscan.bean.ChaXunDetailBean2;
import com.weetop.aklyscan.bean.KuaiDiBean;
import com.weetop.aklyscan.bean.KuaiDiImgBean;
import com.weetop.aklyscan.bean.LogisticsBean;
import com.weetop.aklyscan.bean.MailBean;
import com.weetop.aklyscan.bean.MailBean1;
import com.weetop.aklyscan.bean.MailNumberBean;
import com.weetop.aklyscan.bean.OperationRecordBean;
import com.weetop.aklyscan.bean.OrderDetailBean;
import com.weetop.aklyscan.bean.OrderDetailShowBean;
import com.weetop.aklyscan.bean.SendRecordBean;
import com.weetop.aklyscan.bean.UserInfoBean;
import com.weetop.aklyscan.view.SendOutView;

import java.util.List;

public class SendOutPresent extends BasePresenter<SendOutView> {
    public SendOutPresent(SendOutView baseView, Activity activity) {
        super(baseView, activity);
    }

    public void inquiry(String id, String express_sn, String order_id) {
        addDisposable(apiServer.inquiry("1", id, express_sn, order_id), new BaseObserver<BaseModel<LogisticsBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<LogisticsBean> o) {
                baseView.getInquirySuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void mailType() {
        addDisposable(apiServer.mailType("1", "1"), new BaseObserver<BaseModel<MailBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailBean> o) {
                baseView.getMailTypeSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void updateOrder(String order_sn) {
        addDisposable(apiServer.updateFhOrder("4", order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getupdateOrderSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void surplus(String com){
        addDisposable(apiServer.surplus(com), new BaseObserver<BaseModel<MailNumberBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailNumberBean> o) {
                baseView.getsurplusSuccess(o, com);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void mailType1() {
        addDisposable(apiServer.mailType1("1", "1"), new BaseObserver<BaseModel<MailBean1>>(baseView) {
            @Override
            public void onSuccess(BaseModel<MailBean1> o) {
                baseView.getMailType1Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void editShow(String order_id) {
        addDisposable(apiServer.editShow("4", order_id), new BaseObserver<BaseModel<OrderDetailShowBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<OrderDetailShowBean> o) {
                baseView.getEditShowSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into39(String order_sn, String type) {
        addDisposable(apiServer.Into39(order_sn, type), new BaseObserver<BaseModel<OrderDetailBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<OrderDetailBean> o) {
                baseView.getInto39Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into37(String order_sn) {
        addDisposable(apiServer.Into37(order_sn, "1"), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto37Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into38(String order_sn) {
        addDisposable(apiServer.Into38(order_sn), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto38Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void getKuaiDiImg(String type, String order_sn, String kuaidinum){
        addDisposable(apiServer.Into78(type, order_sn, kuaidinum),
                new BaseObserver<BaseModel<KuaiDiImgBean>>(null) {
                    @Override
                    public void onSuccess(BaseModel<KuaiDiImgBean> o) {
                        baseView.getKuaiDiImgSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.hideLoading();
                            baseView.getKuaiDiImgError();
                            baseView.showError(msg);
                        }
                    }
                });
    }

    public void getKuaiDiCode(String name, String mobile, String printAddr, String count, String weight, String expType,
                              String remark, String tempid, String type_id, String kuaidicom) {
        addDisposable(apiServer.getKuaiDiCode(name, mobile, printAddr, count, weight, "", expType, remark, tempid, "1", type_id, kuaidicom),
                new BaseObserver<BaseModel<KuaiDiBean>>(null) {
                    @Override
                    public void onSuccess(BaseModel<KuaiDiBean> o) {
                        baseView.getKuaiDiCodeSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail("1");
                        }
                    }
                });
    }

    public void Into77(){
        addDisposable(apiServer.Into77(), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto77Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void Into40(String start_time, String end_time) {
        addDisposable(apiServer.Into40(start_time, end_time), new BaseObserver<BaseModel<List<OperationRecordBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<OperationRecordBean>> o) {
                baseView.getInto40Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void upOrder(String order_id, String express_sn, String actual_weight, String cube, String partner_id, String sales_status,
                        String remarks, String express_name, String partner_type) {
        addDisposable(apiServer.upOrder("16", order_id, express_sn, actual_weight, cube, partner_id, sales_status, remarks, express_name, partner_type),
                new BaseObserver<BaseModel<String>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<String> o) {
                        baseView.getUpOrderSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail(msg);
                        }
                    }
                });
    }

    public void baiduToken() {
        addDisposable(apiServer.baiduToken(),
                new BaseObserver<BaseModel<String>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<String> o) {
                        baseView.getBaiduTokenSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail(msg);
                        }
                    }
                });
    }

    public void distinguish(String access_token, String image_url, String order_sn) {
        addDisposable(apiServer.distinguish(access_token, image_url, order_sn),
                new BaseObserver<BaseModel<String>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<String> o) {
//                        baseView.getBaiduTokenSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail(msg);
                        }
                    }
                });
    }




    public void Into41(String order_sn) {
        addDisposable(apiServer.Into41(order_sn), new BaseObserver<BaseModel<ChaXunDetailBean1>>(baseView) {
            @Override
            public void onSuccess(BaseModel<ChaXunDetailBean1> o) {
                baseView.getInto41Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into42(String courier_number) {
        addDisposable(apiServer.Into42(courier_number), new BaseObserver<BaseModel<ChaXunDetailBean2>>(baseView) {
            @Override
            public void onSuccess(BaseModel<ChaXunDetailBean2> o) {
                baseView.getInto42Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into43(String order_sn) {
        addDisposable(apiServer.Into43(order_sn), new BaseObserver<BaseModel<List<SendRecordBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<SendRecordBean>> o) {
                baseView.getInto43Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into44(String print_equipment, String print_ip, String print_ssid, String print_mac, String print_paper_width, String print_paper_height,
                       String print_deviation_x, String print_deviation_y) {
        addDisposable(apiServer.Into44(print_equipment, print_ip, print_ssid, print_mac, print_paper_width, print_paper_height, print_deviation_x,
                print_deviation_y), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto44Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into45() {
        addDisposable(apiServer.Into45(), new BaseObserver<BaseModel<UserInfoBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<UserInfoBean> o) {
                baseView.getInto45Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void expressInfo(String express_sn,String type,String order_sn,String express_code) {
        addDisposable(apiServer.expressInfo("1",express_sn,type,order_sn,express_code), new BaseObserver<BaseModel<LogisticsBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<LogisticsBean> o) {
                baseView.getexpressInfoSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}
